# Maintainer: Jaroslav Lichtblau <dragonlord@aur.archlinux.org>
# Maintainer: Gaetan Bisson <bisson@archlinux.org>
# Contributor: Jeff Mickey <jeff@archlinux.org>
# Contributor: Grigorios Bouzakis <grbzks@gmail.com>
# Contributor: Stephen Gregoratto <dev@sgregoratto.me>

pkgname=fdm
pkgver=2.2
pkgrel=2
pkgdesc='Program to fetch mail and deliver it in various ways'
url='https://github.com/nicm/fdm'
license=('BSD')
arch=('loong64' 'x86_64')
depends=('openssl' 'pcre2' 'tdb' 'zlib')
source=("https://github.com/nicm/fdm/releases/download/${pkgver}/fdm-${pkgver}.tar.gz")
sha256sums=('53aad117829834e21c1b9bf20496a1aa1c0e0fb98fe7735e1e73314266fb6c16')

options=('!makeflags')

build() {
	cd "${pkgname}-${pkgver}"
	./configure --prefix=/usr --enable-pcre2
	make
}

package() {
	cd "${pkgname}-${pkgver}"

	make DESTDIR="${pkgdir}" install

	install -d "${pkgdir}/usr/share/licenses/${pkgname}"
	sed '3,17p;d' fdm.c > "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

	install -d "${pkgdir}/usr/share/doc/${pkgname}"
	cp -a examples MANUAL "${pkgdir}/usr/share/doc/${pkgname}"
}
